<%@page import="com.charlie.beans.Roles"%>
<%@page import="java.util.List"%>
<%!
    public String getParameter(HttpServletRequest request, String name) {
        String value = request.getParameter(name);
        if (value == null) {
            return "";
        }
        return value;
    }
%>

<%@include file="/header.jsp" %>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3.11&libraries=places&sensor=false"></script>
<script type="text/javascript" src="/resources/js/signup.js"></script>
<% if (request.getAttribute("validate") != null) {%>
<script type="text/javascript">
    $(function() {
        email_exist = "${email_exist}";
        $("form").validationEngine('validate');
    });
</script>
<% }%>

<div class="left_side">
    <jsp:include page="/blocks/conditionalLeftBar.jsp" />
</div>

<div class="right_side">
    <h2 class="content_title" style="font-size: x-large;">Create user</h2>

    <div class="white_block">
        <h2  style="font-size: large; text-align: center;">Information about User</h2>   <p>
        <form method="post" >
            E-mail<br> <input type="email" name="email" class="validate[required,custom[email],funcCall[check_email_exist]]" size="50" value="<%= getParameter(request, "email")%>"><br>
            Password<br><input type="password" name="pass" class="validate[required,minSize[1],maxSize[32]]" id="pass" size="50"><br>
            Password again<br><input type="password" name="pass2" class="validate[required,minSize[1],maxSize[32],equals[pass]]" size="50"><br>
            First name<br><input type="text" name="first_name" class="validate[required,minSize[1],maxSize[32],funcCall[check_name]]" size="50" value="<%= getParameter(request, "first_name")%>"><br>
            Last name<br><input type="text" name="second_name" class="validate[required,minSize[1],maxSize[32],funcCall[check_name]]" size="50" value="<%= getParameter(request, "second_name")%>"><br>
            Location<br><input type="text" name="location" id="location" class="validate[required]" size="50" value="<%= getParameter(request, "location")%>"><br>
            <br>

            <%
                List<Roles> roles = (List<Roles>) request.getAttribute("rolesList");
            %>
            <table class="typycal_table">
                <span class="checkRole">            
                    <%
                        if (roles != null)
                            for (Roles r : roles) {
                                if (!r.getRolesName().equals("Admin")) {
                    %>
                    <td>
                        <input type="checkbox" name="id" value="<%=r.getRolesName()%>"><%=r.getRolesName()%></label>
                    </td>
                    <%}
                        }%>
                </span>

                <td><input style="float: right;" type="submit" size="40" value="Submit"></td>
            </table>
        </form>
    </div>

</div>

<%@include file="/footer.jsp" %>
